package com.zr.d_c.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.plaf.synth.SynthScrollBarUI;

import com.zr.d_c.service.FuncService;
import com.zr.d_c.serviceimpl.FuncServiceImpl;

public class DeleteFuncController extends HttpServlet {

	FuncService funcservice = new FuncServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter pw = resp.getWriter();
		String funcNames = req.getParameter("funcs");
		String[] fnames = funcNames.split(",");
		int flag = 0;
		for (int i = 0; i < fnames.length; i++) {
			if(funcservice.deleteFuncByFname(fnames[i])>0){
				flag = 1;
			}else{
				flag = 0;
				break;
			}
		}
		if(flag > 0){
			pw.write("1");
		}else{
			pw.write("0");
		}
		pw.close();
	}
}
